package com.sunny.myproject.sales.util;

import java.util.ArrayList;
import java.util.List;

import org.hibernate.criterion.Criterion;
import org.hibernate.criterion.Restrictions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.sunny.myproject.core.base.util.Base;
import com.sunny.myproject.storem.entity.Store;
import com.sunny.myproject.storem.service.StoreService;

@Component
public class SalesTicketUitl extends Base{

	@Autowired
	private StoreService storeService;
	
	public double getProfits(String name,double d){
		super.criterions = new ArrayList<Criterion>();
		criterions.add(Restrictions.eq("name", name));
		List<Store> stores = storeService.list(criterions);
		Store store = stores.size()>0?stores.get(0):null;
		if(store!=null)
			d -= store.getPrice();
		return d;
	}
}
